Repository navigation
[CodeStyle][py2] remove six package (part1) - #46965
Merged
luotao1 merged 20 commits intoOct 19, 2022
Merged
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
six package (part 1)
Collaborator
luotao1
previously approved these changes
Oct 13, 2022
SigureMo
commented
Oct 13, 2022
| max_sizes = [] | ||
| step = int(math.floor(((max_ratio - min_ratio)) / (num_layer - 2))) | ||
| for ratio in six.moves.range(min_ratio, max_ratio + 1, step): | ||
| for ratio in range(min_ratio, max_ratio + 1, step): |
Collaborator
Author
There was a problem hiding this comment.
这里有一处 docstring 修改
| print("op inputs are {}".format(op.input_arg_names)) | ||
| print("op outputs are {}".format(op.output_arg_names)) | ||
| for key, value in sorted(six.iteritems(op.all_attrs())): | ||
| for key, value in sorted(op.all_attrs().items()): |
Collaborator
Author
There was a problem hiding this comment.
这个 clone 函数示例代码里有几处修改
Ligoml
previously approved these changes
Oct 17, 2022
Collaborator
|
需要解决下冲突 |
Collaborator
|
需要解决下冲突 |
Collaborator
Author
已解决~ |
luotao1
approved these changes
Oct 19, 2022
5 tasks done
six package (part 1)six package (part1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
Others
PR changes
Others
Describe
清理
six模块的第一步,利用 https://github.com/cattidea/paddle-flake8-project/blob/main/flake8_scripts/six_remover.py 自动清理存量较多的 six 函数,手动清理部分难以自动清理的部分,目前清理的部分有明确的映射关系,与代码上下文无关,可安全清理转换规则(大多数可参考 six 文档):
six.moves下的函数:明确的映射,文档里有写six.iteritems(d)->d.items()six.iterkeys(d)->d.keys()six.b(s)six.b("xxx")->b"xxx"six.b(var)->var.encode("latin-1")(与six.bPython3 分支行为一致,单独为前者加一个b前缀是因为可读性更好,而且在源码上就是bytes了,不需要运行时转换)six.u(s)->ssix.<attr>six.string_types->(str, )six.integer_types->(int, )six.class_types->(type, )由于这三个经常以isinstance(x, (str, ))方式使用,因此增加了一个 pass 专门清理这里的括号,也就是清理为isinstance(x, str)six.text_type->strsix.binary_type->bytesif six.PY3: <branch_py3>; else: <branch_py2>-><branch_py3>@six.add_metaclass(Baz); class Foo(Bar)->class Foo(Bar, metaclass=Baz)剩余部分(会在后续 PR 中清理):
six.ensure_str需要根据上下文确定修改方式(类似paddle.compat.to_text)six.reraise修改方案尚未确定,需要进一步确定下python/paddle/fluid/dygraph/dygraph_to_static/convert_call_func.py中的BUILTIN_LIKELY_MODULESpaddle.compat模块相关,在 compat 模块清理时一起清理Related links